<?php

namespace app\admin\model;

use think\Model;


class Store extends Model
{

    protected $pk='storeid';
    // 表名
    protected $name = 'store';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];


    public function storeinfo()
    {
        return $this->hasOne('Storeinfo', 'storeid', 'storeid', [], 'LEFT')->setEagerlyType(0)->bind([
            'images',
            'tel',
            'range',
            'others'
        ]);
    }

    //关联新增
    public function relsave($pk,$data){
        $this->find($pk);
        $this->storeinfo()->save($data);
    }
    //门店评论关联模型
    public function comments(){
        return $this->hasMany('Comment','storeid','storeid',[],'LEFT')->bind([
            'imageData'
        ]);
    }

    public function admin(){
        return $this->belongsTo('Admin','admin_id','id',[],'LEFT');
    }
}
